<?php
$cc_type = 'msw';
foreach ($data as $data_k => $data_v) {
  $pass = 1;
  $update = 0;
  $node = NULL;
  $fe = array();
  $cc = NULL;
  $ccnode = NULL;
  $cctax = NULL;

  $rowcount = $context['results']['row'];
  _flog($log_file, "-- row $rowcount --");

  _flog($log_file, '-- prepare a new record --');
  $check_suffix = array('_zh', '_gb', '_01', '_02', '_03', '_04', '_05');
  $fec = array();
  $images = array();
  $fmatch = array_flip($match);

  $q = db_query('select entity_id from field_data_field_msw_english_name where field_msw_english_name_value = :name', array(':name' => $data_v[0]));
  $obj = $q->fetchObject();
  $existing_nid = empty($obj->entity_id) ? null : $obj->entity_id;
  if (!empty($existing_nid)) {
    _flog($log_file, "-- Load existing $existing_nid --");
    $update = 1;
    $ccnode = node_load($existing_nid);
    $ccnode->field_msw_award_year[LANGUAGE_NONE][0]['value'] = substr($data_v[1], 0 , 4) . "-1-1 00:00:00";
    node_save($ccnode);

  }
  _flog($log_file, "-- row $rowcount $status --");
  $context['results']['row']++;
}


